// 完整的getLocationByIP函数实现
const getLocationByIP = async () => {
  loading.value = true;
  try {
    // 调用腾讯地图IP定位API
    const response = await uni.request({
      url: `https://apis.map.qq.com/ws/location/v1/ip?key=IP6BZ-VFXHT-SJIXQ-LOD5I-FUOXF-J7BPV`,
      method: 'GET',
      header: {
        'content-type': 'application/json'
      }
    });
    
    // 处理不同格式的响应
    let responseData = null;
    if (Array.isArray(response) && response.length >= 2) {
      responseData = response[1];
    } else if (typeof response === 'object' && response !== null) {
      responseData = response.data || response;
    }
    
    if (!responseData || (responseData.status !== 0 && responseData.status !== '0') || !responseData.result || !responseData.result.location) {
      return false;
    }
    
    const ipLat = responseData.result.location.lat;
    const ipLng = responseData.result.location.lng;
    let addressDescription = '定位成功';
    
    // 更新位置信息
    latitude.value = ipLat;
    longitude.value = ipLng;
    locationDesc.value = addressDescription;
    currentAddress.value = addressDescription;
    
    // 存储用户位置信息
    uni.setStorageSync('userLocation', {
      latitude: ipLat,
      longitude: ipLng,
      address: addressDescription,
      timestamp: new Date().getTime()
    });
    
    // 获取附近加油站并更新地图
    await fetchNearbyGasStations(ipLat, ipLng);
    const mockStations = generateMockStationsWithLocation(ipLat, ipLng);
    updateMapMarkers(ipLat, ipLng, mockStations);
    
    // 显示成功提示
    uni.showToast({
      title: 'IP定位成功',
      icon: 'success'
    });
    
    return true;
  } catch (error) {
    console.error('IP定位失败:', error);
    // 显示错误提示
    uni.showToast({
      title: 'IP定位失败，尝试其他方式',
      icon: 'none'
    });
    return false;
  } finally {
    loading.value = false;
  }
};